#include <iostream>
using namespace std;
char bit[4][4];
bool get_right = false;
int min_num=100;

void flip(int n,int m) {
	for (int i = -1; i <= 1; i++)
	{
		for (int j = -1; j <= 1; j++)
		{
			if (i * j == 1 || i * j == -1)
				continue;
			if (n + i >=0 && n + i <= 3 && m + j >=0 && m + j <= 3)
			{
				if (bit[n + i][m + j] == 'b')
					bit[n + i][m + j] = 'w';
				else
					bit[n + i][m + j] = 'b';
			}
		}
	}
}

bool judge() {
	char c = bit[0][0];
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 4; j++) {
			if (bit[i][j] != c)
				return false;
		}
	}
	return true;
}

void round(int n, int m, int num) {
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 4; j++) {
			if (i < n || (i == n && j <= m))
				continue;
			flip(i, j);
			if (judge() && num < min_num) {
				min_num = num;
				get_right = true;
			}
			round(i, j, num+1);
			flip(i, j);
		}
	}
}

int main(void) {
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 4; j++) {
			cin >> bit[i][j];
		}
	}
	if (judge()) {
		min_num = 0;
		get_right = true;
	}
	else {
		round(-1, -1, 1);
	}
	if (get_right) {
		cout << min_num << endl;
	}
	else {
		cout << "Impossible" << endl;
	}
	return 0;
}